Smashing Android Ui: Responsive User Interfaces And Design Patterns For Android Phones And Tablets by Juhani Lehtimäki

Smashing Android Ui: Responsive User Interfaces And Design Patterns For Android Phones And Tablets by Juhani Lehtimäki

Author:Juhani Lehtimäki
Language: eng
Format: epub
Published: 2012-09-25T16:00:00+00:00


Figure 11-12: List items should have a maximum of two clickable components. These components should be placed only at the ends of the list item and the hit areas should be extended to prevent users from making accidental list row selections.

Gallery List

A gallery is a list that is scrolled horizontally while the selected item stays in the middle position. A gallery component is implemented the same way as a list. It is also an adapter view and you can define the items in it freely. The name “gallery” is, therefore, a bit misleading. You can use the gallery to create many styles of horizontally scrolling lists.

The gallery component has some default behaviors that are not present in the vertical list component. The selected item stays horizontally centered and there is a snapping effect when users drag the selection and let go.

Customizing user interface widgets

The Android default components offer a lot of possibilities to customize their look and feel. You can easily modify the colors directly or by using the selector mechanism. You can also extend these components by subclassing them in code; this is a way to add completely new functionality.

Colors

Android has multiple ways to define colors. You can set colors in your layout files as well as in code. In the layout file you can set any color value by defining a hexadecimal color code. The color code can also contain alpha (transparency) value, but it doesn’t have to.

The following syntaxes are allowed in the layout definitions. A = alpha, R = red, G = green, and B = blue.

• #AARRGGBB

• #RRGGBB

• ARGB

• #RGB

To define colors that are easier to maintain and reuse, you can define colors as resources. Add a file, for example colors.xml, in your res/values/ project folder. In that file you can add color resources like in the following example code.

<?xml version=”1.0” encoding=”utf-8”?>

<resources>

<color name=”background_color”>#FFFFF0</color>

</resources>

By doing this you can refer to these colors whenever you need to define a color in your layout or code. Using color files has two great benefits:

• You can easily change your colors uniformly by changing the code in one place only.

• You can also easily change the whole theme of your app if you’re creating multiple versions by simply replacing the color file in a build script or overriding it in a project where you use the original project as a library project.

Selectors

A selector is a great concept that can help you with any components that have different states, such as a button’s down and focused states.

A selector is a XML file added in the res/drawable project folder. It defines a set of items that have state parameters and tells the operating system which of the items should be used and when. You can put anything inside the item element that you can use to draw from XML. I’ll talk about drawing from XML more in Chapter 14.

The following example is probably the simplest selector possible. If you put this example code into your project’s res/drawable/example_selector.xml file, you can use it as a background for



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Eco-friendly approach of bio-indigo synthesis and developing purification methods towards isolation of indigo from indirubin and bacterial fragments by Ramalingam Manivannan & Kaliyan Prabakaran & Young-A Son(204625)
Personalized inhaled bacteriophage therapy for treatment of multidrug-resistant Pseudomonas aeruginosa in cystic fibrosis by unknow(173126)
CONSORT 2025 statement: updated guideline for reporting randomized trials by unknow(81607)
Critical evaluation of the ProfiLER-02 study design and outcomes by Vivek Subbiah & Razelle Kurzrock(81191)
Cardiac gene therapy makes a comeback by Oliver J. Müller & Susanne Hille & Anca Kliesow Remes(80960)
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(74430)
Unveiling the design rules for tunable emission in graphene quantum dots: A high-throughput TDDFT and machine learning perspective by Şener Özönder & Mustafa Coşkun Özdemir & Caner Ünlü(50884)
A yeast-based oral therapeutic delivers immune checkpoint inhibitors to reduce intestinal tumor burden by unknow(40256)
Covalent hitchhikers guide proteins to the nucleus by Alexander F. Russell & Madeline F. Currie & Champak Chatterjee(40214)
Meet the Authors: Christopher R. Mansfield and Emily R. Derbyshire by Christopher R. Mansfield & Emily R. Derbyshire(40091)
Alkaline-earth metals promote propane dehydrogenation with carbon dioxide through geometric effects: Altering the reaction pathway by unknow(32728)
Induced iron vacancies boosting FeOOH loaded on sustainable Fenton-like collagen fiber membrane for efficient removal of emerging contaminants by unknow(32503)
Efficient electric-field-assisted photochemical conversion of methane to n-propanol exclusively over penetrated TiO2Ti hollow fibers by Guanghui Feng(32451)
Bi2SiO5 nanosheets as piezo-photocatalyst for efficient degradation of 2,4-Dichlorophenol by Hangyu Shi & Yifu Li & Lishan Zhang & Guoguan Liu & Qian Zhang & Xuan Ru & Shan Zhong(32382)
A novel NDIPTA organic heterojunction photocatalyst with built-in electric field for efficient hydrogen production by Jiahui Yang & Baojun Ma & Yongfa Zhu(32359)
Enhanced conversion of methane to liquid-phase oxygenates via hollow ferrite nanotube@horseradish peroxidase based photoenzymatic catalysis by Jun Duan & Shiying Fan & Xinyong Li & Shaomin Liu(32330)
Ordered macroporous superstructure of defective carbon adorned with tiny cobalt sulfide for selective electrocatalytic hydrogenation of cinnamaldehyde by Xiao-Shi Yuan & Sheng-Hua Zhou & San-Mei Wang & Wenbo Wei & Xiaofang Li & Xin-Tao Wu & Qi-Long Zhu(32256)
What's Done in Darkness by Kayla Perrin(27139)
Topological analysis of non-conjugated ethylene oxide cored dendrimers decorated with tetraphenylethylene: Insights from degree-based descriptors using the polynomial approach by A Theertha Nair & D Antony Xavier & Annmaria Baby & S Akhila(26518)
Investigation of mechanical and self-healing properties of hydroxyl-terminated polybutadiene functionalized with 2-ureido-4-pyrimidinone by Mohsen Kazazi & Mehran Hayaty & Ali Mousaviazar(26454)